import { createRouter, createWebHistory } from 'vue-router'
import Layout from '@/views/Layout/Layout.vue'
import Home from '@/views/Home/Home.vue'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  //滚动条重置
  scrollBehavior () {
    return { top: 0 }
  },
  routes: [
    
   {
    path:'/',
    name:'layout',
    component:Layout,
    children:[
      {
        path:'',
        name:'home',
        component:Home
      },
      {
        path:'/category/:id',
        name:'category',
        component:()=>import('@/views/Category/Category.vue')
      },
      {
        path:"/category/sub/:id",
        name:'subcategory',
        component:()=>import('@/views/SubCategory/SubCategory.vue')
      },
      {
        path:"/detail/:id",
        name:'detail',
        component:()=>import('@/views/GoodsDetail/GoodsDetail.vue')
      },
    ]
   },
   {
    path:'/login',
    name:'login',
    component:()=>import('@/views/Login/Login.vue')
   }
  ],
})

export default router
